package com.shop.mall.utils;

import java.util.UUID;

/**
 * @author admin
 * @version 1.0
 * @date 2019/5/15
 */
public class GetUUIDUtil {
    public static String getId() {
        UUID uuid = UUID.randomUUID();
        String[] id = uuid.toString().split("-");
        return id[1];
    }

    public static void main(String[] args) {
        UUID uuid = UUID.randomUUID();
        String str = uuid.toString();
        // 去掉"-"符号
        String temp = str.substring(0, 8) + str.substring(9, 13) + str.substring(14, 18) + str.substring(19, 23) + str.substring(24);
        System.out.println(str + "," + temp);
        //获得4个长度的十六进制的UUID
        String[] idd = uuid.toString().split("-");
        System.out.println(idd[1]);
    }
}
